package com.yinlixian.frame.admin.controller;

import com.yinlixian.frame.admin.entity.SysUser;
import com.yinlixian.frame.admin.service.ISysUserService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Date;

/**
 * <p>
 * 用户信息 前端控制器
 * </p>
 *
 * @author yudm
 * @since 2017-03-01
 */
@RestController
@RequestMapping("/sysUser")
public class SysUserController {

    @Autowired
    private ISysUserService iSysUserService;

    @RequestMapping(value = "/create")
    @RequiresPermissions("sysUser:create")
    public SysUser createUser( SysUser sysUser){
        System.out.println("创建用户");
        SysUser user = new SysUser();
        user.setLoginName("tset");
        user.setUsername("中文名");
        user.setPassword("213123");
        user.setStatus(1);
        user.setCreateUserId(1);
        user.setCreateTime(new Date());
        user.setDelete(false);
//        boolean insert = iSysUserService.insert(user);
        return user;
    }

    @RequestMapping(value = "/update")
    public String updateUser( @Valid SysUser sysUser){
        System.out.println("更新用户="+sysUser.toString());
        SysUser user = new SysUser();
        user.setLoginName("tset123");
        user.setUsername("中文名123");
//        return user;
        int i = 1/0;
        return null;
    }

}
